package com.telit.firecommand.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaolyuh.annotation.CacheEvict;
import com.telit.firecommand.dto.CameraFirePointDTO;
import com.telit.firecommand.entity.CommCameraInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * CommCameraInfoDAO
 *
 * @author yuezhuang
 * @since 2022-12-22
 */
@Repository
public interface CommCameraInfoDao extends BaseMapper<CommCameraInfo> {

    /**
     * 条件修改监控
     *
     * @param commonCameraInfo
     */
    void updateByNameAndType(CommCameraInfo commonCameraInfo);

    @CacheEvict(value = {"firecommand:camera:queryNameById", "firecommand:camera:queryNameByIds"}, allEntries = true)
    int updateByPrimaryKeySelective(CommCameraInfo record);

    int insertSelective(CommCameraInfo record);

    @CacheEvict(value = {"firecommand:camera:queryNameById", "firecommand:camera:queryNameByIds"}, allEntries = true)
    int deleteByPrimaryKey(Long id);


    /**
     * 分页查询监控设备
     *
     * @param iPage
     * @param districtCode
     * @param name
     *
     * @return
     */
    IPage<CommCameraInfo> selectByPage(IPage<CommCameraInfo> iPage, @Param("districtCode") String districtCode,
                                       @Param("monitoringType") String monitoringType, @Param("name") String name,
                                       @Param("deviceStatus") String deviceStatus);

    /**
     * 条件查询单台监控设备
     *
     * @param cameraName
     * @param monitoringType
     * @param pictureType
     *
     * @return
     */
    CommCameraInfo queryByNameAndType(@Param("cameraName") String cameraName,
                                      @Param("monitoringType") String monitoringType,
                                      @Param("pictureType") Integer pictureType,
                                      @Param("deviceStatus") String deviceStatus,
                                      @Param("districtCode") String districtCode);

    int countCamera(@Param("districtCode") String districtCode, @Param("monitoringType") String monitoringType,
                    @Param("deviceStatus") String deviceStatus);


    List<CameraFirePointDTO> queryListByPoint(@Param("firePoint") String firePoint,
                                              @Param("districtCode") String districtCode);

    /**
     * 条件查询摄像头信息
     *
     * @param keyWord
     * @param deviceStatus
     *
     * @return
     */
    List<CommCameraInfo> queryByCondition(@Param("keyWord") String keyWord, @Param("deviceStatus") String deviceStatus,
                                          @Param("monitoringType") String monitoringType,
                                          @Param("districtCode") String districtCode);

    /**
     * 根据监控id查询实时视频流
     *
     * @param cameraId
     *
     * @return
     */
    String queryIndexCode(@Param("cameraId") Long cameraId);

    CommCameraInfo selectByPrimaryKey(Long id);

    void updateStatusById(@Param("id") Long id,@Param("deviceStatus") String deviceStatus);
}
